public class demo4 {
    public String convert(String s, int numRows) {
        int n=s.length();
        int sum=0;
        int m=1;
        int x=0,y=0;
        if (numRows==1||numRows>=n) {
            return s;
        }
        char [][]arr=new char[numRows][n];
        int t=2*numRows-2;
        for(int i=0;i<n;i++){
            arr[x][y]=s.charAt(i);
            if(i%t<numRows-1){
                x++;
            }else{
                x--;
                y++;
            }
        }
        StringBuilder stringBuilder=new StringBuilder();
        for (int i=0;i<numRows;i++){
            for (int j=0;j<n;j++){
                if(arr[i][j]!='\u0000')stringBuilder.append(arr[i][j]);
            }
        }
        return stringBuilder.toString();
    }
}
